jQuery(document).ready(function() {

		var articleDir = "articles/";
		jQuery.getJSON("../articles.json", function(data) {

			if(data){ //check if any data is returned
				jQuery.each(data, function(key,val) {
				//		console.log(val);
				jQuery("#tbBody").append('<tr>' +
      									 '<td id="statCol">' + val.title +'</td>' +
										 '<td class="lft"><a href="' + articleDir + val.filename +'">' + val.filename + '</a></td>' +
										 '<td><i>' + val.author + '</i></td>' +
										 '<td>' + val.date +'</td>' +
										 '</tr>');
				});
			}		
			else {
				console.log("Aw Snap! : Something went wrong loading the articles");
			}
		
		});

		});

// A quick demo of how to have "static" data columns within your table
// Just call staticData.parse(tableId, [column index array]) to parse the initial data
// and add a "sortcompletecallback-staticData-redraw" class to the table
var staticData = (function() {
        var columnData = {};
        
        function parseStaticColumn(tableID, colNums) {
                // Grab the TR nodes (I'm assuming the table has a TBODY)
                var trs     = document.getElementById(tableID).getElementsByTagName('tbody')[0].getElementsByTagName('tr'),
                    dataObj = [],
                    colData;
                
                // Make sure that the colNums is an Array 
                // N.B: This enables you to pass an integer if you only require one static column for the table
                // - as is done within this demo
                if(!colNums.length) { colNums = [colNums]; }
                    
                // Loop through the TR node collection and cache the required colData
                for(var i = 0, tr; tr = trs[i]; i++) { 
                        colData = [];
                        for(var z = 0; z < colNums.length; z++) {                                                                 
                                // Grab the current "colNum" TD within this TR and store it's (text) data 
                                // I'm reusing a method "getInnerText" made available by the tableSort script
                                colData[z] = fdTableSort.getInnerText(tr.getElementsByTagName("td")[colNums[z]]);
                        };
                        dataObj[i] = colData;                        
                };
                
                // Cache the results for this table
                columnData[tableID] = {
                        data:dataObj,
                        cols:colNums
                        };
        };
        
        function sortCompleteCallback(tableID) {
 /*               // Grab the TR's and the stored data object
                var trs     = document.getElementById(tableID).getElementsByTagName('tbody')[0].getElementsByTagName('tr'),
                   // dataObj = columnData[tableID].data,
                   // colNums = columnData[tableID].cols,                    
                    cell;
                    
                // Loop through the TR node collection
                for(var i = 0, tr; tr = trs[i]; i++) {                         
                        for(var z = 0; z < colNums.length; z++) {                                                               
                                // Grab the "colNum" TD within this TR
                                cell = tr.getElementsByTagName("td")[colNums[z]];
                                // Delete it's contents
                                while(cell.firstChild) cell.removeChild(cell.firstChild);
                                // Append a text node containing the stored data
                                cell.appendChild(document.createTextNode(dataObj[i][z]));
                        };
                };
*/				
        };
        
        return {
                parse : parseStaticColumn,
                redraw: sortCompleteCallback
        };
})();